package xml.uidElements.output;

import java.util.ArrayList;

import xml.others.UIDException;
import xml.uidElements.Transition;

public class OutputDataItem extends AbstractOutputDataItem {
	private String name;
	private String domain;
	private boolean optional = false;
	private ArrayList<Transition> listOutgoingTransitions;

	public OutputDataItem(String name) {
		this.name = name;
		this.domain = null;
	}

	public OutputDataItem(String name, String domain) {
		this.name = name;
		this.domain = domain;
	}

	@Override
	public String getName() {
		return name;
	}

	public String getDomain() {
		return domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}

	public void setOptional(boolean optional) {
		this.optional = optional;
	}

	public boolean isOptional() {
		return optional;
	}

	public void insertOutgoingTransition(Transition transition) {

		if (listOutgoingTransitions == null)
			listOutgoingTransitions = new ArrayList<Transition>();

		for (int i = 0; i < this.listOutgoingTransitions.size(); i++) {
			Transition trans = this.listOutgoingTransitions.get(i);
			if (trans.getId().equals(transition.getId()))
				throw new UIDException(UIDException.EXISTING_TRANSITION,
						"There is already a transition with this id");
		}
		listOutgoingTransitions.add(transition);

	}
}
